SOURCES=boot.o util.o video.o print.o tables.o isr.o \
timer.o kb.o kheap.o paging.o ordered_array.o \
initrd.o fs.o task.o syscall.o main.o 
CFLAGS=-nostdlib -nostdinc -fno-builtin -fno-stack-protector -c
LDFLAGS=-Tlink.ld
ASFLAGS=-felf

all: $(SOURCES) link copy

clean:
	-rm *.o kernel.bin

link:
	ld $(LDFLAGS) -o kernel.bin $(SOURCES)

.s.o:
	nasm $(ASFLAGS) $<

copy:
	losetup /dev/loop0 floppy_module.img
	sudo mount -o loop /dev/loop0 /mnt/fd0
	sudo cp kernel.bin /mnt/fd0/mykern/
	sudo cp initrd.img /mnt/fd0/initrd
	sudo umount /mnt/fd0
	losetup -d /dev/loop0
